package controller

import (
	"fmt"
	"git.900sui.cn/kc/apiPay/constKey"
	"git.900sui.cn/kc/base/common/functions"
	"git.900sui.cn/kc/redis"
	redis2 "github.com/gomodule/redigo/redis"
)

type H5Controller struct {
	functions.Controller
}

const (
	NET_ERR = "网络故障，稍后再试"
	ORDER_NO = "未查询到订单信息"
)

//H5网关支付
func (h *H5Controller) WapPay()  {
	orderSn := h.Input.GetPost("orderSn", "").String()
	h.Ctx.Header("Content-type", "text/html; charset=utf-8")
	if len(orderSn) == 0{
		h.Ctx.String(200,ORDER_NO)
		return
	}
	h5Key := fmt.Sprintf(constKey.H5_PAY_HTML_INFO, orderSn)
	payHtml, err := redis2.String(redis.RedisGlobMgr.Get(h5Key))
	if err != nil && err.Error() != "redigo: nil returned"{
		h.Ctx.String(200,NET_ERR)
		return
	}
	if len(payHtml) == 0{
		h.Ctx.String(200,ORDER_NO)
		return
	}
	h.Ctx.String(200,payHtml)
}
